home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip1292.zip / VIDEO_1.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  2KB  |  82 lines

  1. unsigned int *screen;    /* pointer to screen memory */
  2. unsigned int vbase;      /* segment of video base */
  3. unsigned int maxx;       /* number of columns */
  4. unsigned int maxy;       /* number of rows */
  5. union REGS r;
  6. struct SREGS sr;
  7. int vmode = 0;
  8.  
  9. /* get display mode */
  10.  
  11. r.h.ah = 0x0f;
  12. int86(0x10,&r,&r);
  13.  
  14. vmode = r.h.al;
  15.  
  16. /* guess what!?
  17.    it returns the number of columns too! */
  18.  
  19. if (maxx == 0)
  20.         maxx = (int) r.h.ah;
  21.  
  22. /* number of rows is harder */
  23.  
  24. if (maxy == 0)
  25. {
  26.         /* try using a ega/vga function */
  27.  
  28.         r.x.ax = 0x1130;
  29.         r.x.dx = maxy;
  30.         int86(0x10,&r,&r);
  31.  
  32.         /* if it fails, it returns 0, so we set
  33.            the screen to 25 lines, otherwise
  34.            it returns the actual number of lines
  35.            of text on the screen */
  36.  
  37.         maxy = (r.x.dx == 0) ? 25 : (r.x.dx + 1);
  38. }
  39.  
  40. if (vbase == 0)
  41.  
  42.         /* if you are in mode 7 the video is
  43.            most likely based at 0xB000, otherwise
  44.            it will be at 0xB800.  This fails for
  45.            a small number of cards, like the
  46.            genius mono displays (although, i've
  47.            never had a failure reported... */
  48.  
  49.         if (vmode == 0x07)
  50.                 vbase = 0xb000;
  51.         else    vbase = 0xb800;
  52.  
  53. r.h.ah = 0xfe;
  54. sr.es = vbase;
  55.  
  56. /* if we are running desqview or topview,
  57.    this function returns the segment of a video
  58.    buffer to use, otherwise it returns the
  59.    value in es unchanged */
  60.  
  61. r.x.di = 0;
  62. int86x(0x10,&r,&r,&sr);
  63.  
  64. desqview = (vbase != sr.es);
  65. vbase = sr.es;
  66.  
  67. /* make my screen pointer */
  68.  
  69. screen = (unsigned int *) MK_FP(vbase,r.x.di);
  70.  
  71. /*
  72.  
  73. incidentally, if you are in a vmode<7 and the number of
  74. screen lines is greater than 25, it means you are in
  75. 43/50 line mode and should either remain there or reset
  76. it when you get done.
  77.  
  78. jim nutt
  79. 'the computer handyman'
  80.  
  81. */
  82.